package com.lyf.core.presenter;

import com.blankj.utilcode.util.NetworkUtils;
import com.lyf.core.presenter.view.BaseView;
import com.trello.rxlifecycle4.LifecycleTransformer;

public class BasePresenter<T extends BaseView> {

    private T mView;
    private LifecycleTransformer mLifecycleTransformer;
    public   final String TAG = getClass().getSimpleName();

    public void attachView(T view){
        this.mView = view;
    }

    public void addObserver(LifecycleTransformer lifecycleTransformer){
        mLifecycleTransformer=lifecycleTransformer;
    }

    public void detachView(){

    }

    public T getView() {
        return mView;
    }

    public <T> LifecycleTransformer<T> getLifecycleProvider() {
        return mLifecycleTransformer;
    }

    protected boolean checkNetWork(){
        if (NetworkUtils.isConnected()){
            return true;
        }
        mView.showMessage("网络不可用");
        return false;
    }

}
